#pragma once
#include <iostream>
#include <string>
#include <regex>

void test_regex()
{
    std::string line = "GET /search?q=http&limit=10 HTTP/1.1";
    // std::regex e("/numbers/(\\d+)/(\\d+)");

    // std::smatch matchs;
    // bool ret = std::regex_match(src,matchs,e);
    // if(ret == false)
    // {
    //     std::cout<<"解析失败"<<std::endl;
    // }

    std::smatch matches;
    std::regex e("(GET|HEAD|POST|PUT|DELETE) ([^?]*)(?:\\?(.*))? (HTTP/1\\.[01])(?:\n|\r\n)?", std::regex::icase);
    bool ret = std::regex_match(line, matches, e);
    for (auto &s :  matches)
    {
        std::cout << s << std::endl;
    }
}